<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <title>Document</title>
</head>
<body>
    <script>
        var ary = new Array(12,35,78,52)
        function fn(){
            len = ary.length        
            for (i = 0;i < len - 1;i++){
                for(j = 0;j < len - 1 - i;j++){
                    if(ary[j]>ary[j+1]){
                        var a = ary[j]
                        ary[j] = ary[j+1]
                        ary[j+1] = a
                    }
                }                
            } 
        }          
    </script>
</body>
</html>